package kpi.java_training.testing.user;

import kpi.java_training.testing.db.CSVParser;
import kpi.java_training.testing.userInterface.Input;
import kpi.java_training.testing.userInterface.Output;

import java.util.ArrayList;

/**
 * User: Alex Palleev
 * Date: 07.11.13
 * Time: 17:12
 */
public class UserManager {
    private String userName;
    private String userPassword;

    private User user;
    private CSVParser csvParser;

    public UserManager() {
        this.userName = "";
        this.userPassword = "";
        this.user = null;
        this.csvParser = new CSVParser();
    }

    public void inputUserName() {
        Input input = new Input();
        Output output = new Output();

        output.showString("Input user name:");
        userName = input.getString();
    }

    public String getName() {
        return user.getName();
    }


    public void inputUserPassword() {
        Input input = new Input();
        Output output = new Output();

        output.showString("Input user password:");
        userPassword = input.getString();
    }

    public String getUserType() {
        return user.getUserType();
    }

    public User getUser() {
        return user;
    }

    public void authenticateUser() {
        user = csvParser.authenticateUser(userName, userPassword);
    }

    public void getUsersStatistics(){
        ArrayList<String> statistics = csvParser.getStatistics();
        Output output = new Output();

        for (String userStatistic : statistics){
            output.showLine(userStatistic);
        }
    }
}
